package com.scsj.supermarket.adapter;


import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.scsj.supermarket.R;
import com.scsj.supermarket.customview.GridSpacingItemDecoration;
import com.vondear.rxtools.RxImageTool;

import java.util.ArrayList;
import java.util.List;

/**
 * 店铺—商品分类
 */

public class ShopClassifyAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private Context mContext;

    public ShopClassifyAdapter(Context mContext, List data) {
        super(R.layout.item_shop_classify, data);
        this.mContext = mContext;
    }

    @Override
    protected void convert(final BaseViewHolder helper, final String item) {
        helper.setText(R.id.name, item);
        if (item.equals("个护美妆")) {
            helper.getView(R.id.child_ll).setVisibility(View.VISIBLE);
            RecyclerView recyclerView = helper.getView(R.id.child_recyclerview);
            recyclerView.setLayoutManager(new GridLayoutManager(mContext, 2));
            recyclerView.setNestedScrollingEnabled(false);
            recyclerView.addItemDecoration(new GridSpacingItemDecoration(2, RxImageTool.dp2px(10), false));
            List<String> list = new ArrayList<>();
            list.add("口腔护理");
            list.add("美容剃须");
            list.add("面部护理");
            list.add("女性护理");
            list.add("身体护肤");
            list.add("洗发没法");
            ShopClassifyChildAdapter childAdapter = new ShopClassifyChildAdapter(list);
            recyclerView.setAdapter(childAdapter);
        } else {
            helper.getView(R.id.child_ll).setVisibility(View.GONE);
        }
    }
}
